package com.abe.mvp.presenter;

import com.abe.mvp.contact.WebServerContact;
import com.abe.mvp.contact.WebServerContact.Model.IWebServerBack;
import com.abe.mvp.model.WebServerModelImp;
import com.abe.mvp.model.bean.http.ExerciseBean;

public class HttpExercisePresenter implements
		WebServerContact.ExercisePresenter {

	private WebServerContact.Model mModel;
	private WebServerContact.ExercideUploadView mView;

	public HttpExercisePresenter(WebServerContact.ExercideUploadView mView) {
		this.mView = mView;
		this.mModel = new WebServerModelImp();
	}

	@Override
	public void uploadExerciseData(ExerciseBean bean) {
		mModel.uploadExerciseData(bean, new IWebServerBack() {
			@Override
			public void onResult(int code, Object data, String errorMSG) {
				if (code == 1) {
					mView.onExerciseUploadSuccess();
				} else {
					mView.onRequestFail(errorMSG);
				}
			}

			@Override
			public void onFinish() {
				mView.onFinish(WebServerContact.TYPE_EXERCISE);
			}
		});
	}

}
